<%--
  Created by IntelliJ IDEA.
  User: WY2015092804
  Date: 2015/10/15
  Time: 13:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="st" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="easyui" uri="http://www.joyi.cn/easyui/tags" %>
<%@ taglib prefix="j" uri="j/tags" %>
<%@ taglib prefix="joyi" uri="http://www.joyi.cn/tags" %>
<st:page title="地">

    
    <div data-options="region:'west',title:'地区列表',split:true" style="width: 300px">
        <%--<table id="tt" class="easyui-treegrid"--%>
               <%--data-options="toolbar:'#toolbarcity',fit:true,url:'/user/req?rid=<j:des data="20151015000000000015" />',idField:'id',treeField:'name',onClickRow:aaa">--%>
            <%--<thead>--%>
            <%--<tr>--%>
                <%--<th data-options="field:'id',formatter:formatth,width:70">操作</th>--%>
                <%--<th data-options="field:'name',width:230">地区列表</th>--%>
            <%--</tr>--%>

            <%--</thead>--%>
        <%--</table>--%>
        <joyi:dataGrid id="cityList" key="getCityList" toolbarId="toolbarcity" />
            
        <div id="toolbarcity">
            <easyui:linkButton name="添加地区" iconKey="add" onClick="editCity()"/>
        </div>

    </div>
    <div data-options="region:'center',title:'客户列表',split:true" >
        <joyi:dataGrid id="custormerList" key="custormerLisOn" toolbarId="addCustormer"/>
        <div id="addCustormer">
            <easyui:linkButton name="添加客户" iconKey="add" onClick="editCustormer();"/>
        </div>
    </div>
    <script>
        function editCity(id) {
            j.open("/user/req?rid=<j:des data="20151015000000000016"/>&cityId=" + id, "editCity", {title: "编辑地区"}, 500, 400);
        }

        function delCity(id) {
            if (window.confirm("确定要删除么？")) {
                Http.post("/user/req?rid=<j:des data="20151015000000000017"/>", {cityId:id}, function (data) {
                    alert(data.data["da"]);
                    reloadTreegrid();
                });
            }
        }

        function formatth(value, data, index) {
            var th = "<a href='javascript:void(0)' onclick='editCity(\"" + value + "\")' >修改</a>";
            th += "<a href='javascript:void(0)' onclick='delCity(\"" + value + "\")' >删除</a>";
            return th;
        }

        function onClickCity(a,b,c){
            $("#custormerList").datagrid("load",{
                cityId: a.cityId
            });
        }


        function reloadTreegrid() {
            $("#cityList").treegrid("reload");
        }

        function reloadList() {
            reloadTreegrid();
        }

        //编辑客户信息
        function editCustormer(id){
            j.open("/user/req?rid=<j:des data=""/>custormerId="+id,"editCustormer",{title:"编辑客户信息"},500,400);
        }
        //删除客户
        function delCustormer(id){
            if(window.confirm("确定要删除么？")){
                Http.post("/user/req?rid=<j:des data=""/>",{custormerId:id},function(data){
                    alert(data.data.acc);
                    reloaddatagrid();
                });
            }
        }

        function reloaddatagrid(){
            $("#custormerList").datagrid("reload");
        }

    </script>
</st:page>

